package com.kaiyidiannao.activity.secondhandcar;


import android.content.Intent;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.View;
import android.widget.*;
import com.kaiyidiannao.activity.login_or_registered.LoginOrRegistered;
import com.kaiyidiannao.activity.user_detail.EditUserDetail;
import com.kaiyidiannao.adapter.SecondCarCommonAdapter;
import com.kaiyidiannao.adapter.SecondHandCarAdapter;
import com.kaiyidiannao.adapter.SortAdapter;
import com.kaiyidiannao.common.BaseActionBarActivity;
import com.kaiyidiannao.common.pulltorefresh_view.DragListView;
import com.kaiyidiannao.common.util.CharacterParser;
import com.kaiyidiannao.common.util.PinyinComparator;
import com.kaiyidiannao.common.util.SortModel;
import com.kaiyidiannao.data.DataCenter;
import com.kaiyidiannao.https.HttpUtils;
import com.kaiyidiannao.main.R;
import com.kaiyidiannao.model.bean.SecondHandCar;
import com.kaiyidiannao.model.bean.UserBean;
import com.kaiyidiannao.model.req.model.GetSecondHandCarLIst;
import com.kaiyidiannao.model.req.model.GetSecondHandCarLIstTop;
import com.kaiyidiannao.model.req.model.GetSecondHandCarSearch;
import com.kaiyidiannao.view.ActionBarView;
import com.kaiyidiannao.view.AutoTextView;
import com.taplinker.core.util.LogUtil;

import java.util.*;

/**
 * Created by mark on 2014/4/14.
 */
public class SecondHandCarActivity extends BaseActionBarActivity implements Observer {
    public CharacterParser characterParser;
    public boolean flag = false;
    private ArrayList<String> list1 = new ArrayList<String>();
    private ArrayList<String> list2 = new ArrayList<String>();
    private ArrayList<String> list3 = new ArrayList<String>();
    private PinyinComparator pinyinComparator;
    private ArrayList<UserBean> userBeans = DataCenter.userLogin;
    private ArrayList<UserBean> beans = DataCenter.userBeans;
    private LinearLayout linearLayout;//根view
    private AutoTextView mTextView02;
    private RelativeLayout rl_car;
    private List<SortModel> SourceDateList = new ArrayList<SortModel>();
    private SecondHandCarAdapter secondHandCarAdapter = null;
    private ProgressBar progressBar;
    private ListView lv_car;
    private SecondCarCommonAdapter adapter;
    private SortAdapter sortAdapter;
    private TextView secondHandCarName, secondHandCarPrice, secondHandCarKM, secondHandCarAge;
    private List<SecondHandCar> secondHandCarLists = DataCenter.secondHandCar;
    private DragListView secondHandCarList;
    FragmentActivity secondHandCarActivity = null;
    private View no_content_view;//没有数据的布局对象
    //请求数据参数
    private int catid = DataCenter.secondHandCar_category_id;
    private int currentPage = DataCenter.LISTVIEW_DEFAULT_PAGE;
    int page = DataCenter.LISTVIEW_DEFAULT_PAGE;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.secondhandcar);
        // 添加观察者
        DataCenter.getInstance().addObserver(this);
        catid = DataCenter.secondHandCar_category_id;
        DataCenter.rolling_current_module_id = DataCenter.moduleFlag.secondhandcar;
        findView();
        initView();
        findActionBar();

        actionBarView.button_right_icon2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (userBeans.size() == 0) {
                    Intent intent = new Intent(SecondHandCarActivity.this, LoginOrRegistered.class);
                    intent.putExtra("ClassName", SecondHandCarActivity.class.getName());
                    startActivity(intent);
                    Log.d("classname", SecondHandCarActivity.class.getName());
                    Toast.makeText(SecondHandCarActivity.this, "请先登录", Toast.LENGTH_SHORT).show();
                    //finish();
                } else if (beans.get(0).getUsername() == null || beans.get(0).getUsername().equals("")) {
                    Intent intent = new Intent(SecondHandCarActivity.this, EditUserDetail.class);
                    intent.putExtra("ClassName", SecondHandCarActivity.class.getName());
                    startActivity(intent);
                    Toast.makeText(SecondHandCarActivity.this, "请完善您的个人信息", Toast.LENGTH_SHORT).show();
                    // finish();
                } else {
                    Intent intent = new Intent(SecondHandCarActivity.this, SecondHandCarPublish.class);
                    startActivity(intent);
                }
            }
        });

        secondHandCarList.setVisibility(View.VISIBLE);
        mTextView02.setVisibility(View.VISIBLE);
        progressBar.setVisibility(View.VISIBLE);
        new GetSecondHandCarLIst(catid).execute();
        if (!HttpUtils.isConnected()) {

        } else {
            new GetSecondHandCarLIstTop(catid).execute();
        }


    }


    public void findView() {
        lv_car = (ListView) findViewById(R.id.lv_car);
        no_content_view = findViewById(R.id.no_content_view);
        secondHandCarName = (TextView) findViewById(R.id.secondHandCarName);
        secondHandCarPrice = (TextView) findViewById(R.id.secondHandCarPrice);
        secondHandCarKM = (TextView) findViewById(R.id.secondHandCarKM);
        secondHandCarAge = (TextView) findViewById(R.id.secondHandCarAge);
        secondHandCarList = (DragListView) findViewById(R.id.secondHandCarList);
        rl_car = (RelativeLayout) findViewById(R.id.rl_car);
        mTextView02 = (AutoTextView) findViewById(R.id.switcher02);
        progressBar = (ProgressBar) findViewById(R.id.second_inner_progress_bar);
        secondHandCarAdapter = new SecondHandCarAdapter(this, secondHandCarLists);
        secondHandCarList.setAdapter(secondHandCarAdapter);
        secondHandCarAdapter.notifyDataSetChanged();
        secondHandCarList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(SecondHandCarActivity.this, SecondHandCarDetail.class);
                Bundle bundle = new Bundle();
                intent.putExtra("catid", secondHandCarLists.get(position - 1).getCatid());
                intent.putExtra("itemid", secondHandCarLists.get(position - 1).getItemid());
                intent.putExtra("catid", secondHandCarLists.get(position - 1).getCatid());
                intent.putExtra("addtime", secondHandCarLists.get(position - 1).getAddtime());
                intent.putExtras(bundle);
                startActivity(intent);
                DataCenter.car_position = position - 1;
                DataCenter.PAGE = (position - 1) / 10 + 1;
                currentPage = (position - 1) / 10 + 1;
            }
        });
        secondHandCarList.setOnRefreshListener(new DragListView.OnRefreshLoadingMoreListener() {
            @Override
            public void onRefresh() {
                progressBar.setVisibility(View.VISIBLE);
                if (flag) {
                    new GetSecondHandCarSearch(DataCenter.index1, DataCenter.brandName, DataCenter.index3, DataCenter.index2, page).execute();
                    page = DataCenter.LISTVIEW_DEFAULT_PAGE;
                } else {
                    new GetSecondHandCarLIst(catid, DataCenter.LISTVIEW_DEFAULT_PAGE).execute();
                    currentPage = DataCenter.LISTVIEW_DEFAULT_PAGE;
                }
            }

            @Override
            public void onLoadMore() {
                progressBar.setVisibility(View.VISIBLE);
                if (flag) {
                    new GetSecondHandCarSearch(DataCenter.index1, DataCenter.brandName, DataCenter.index3, DataCenter.index2, ++page).execute();
                } else {
                    new GetSecondHandCarLIst(catid, ++currentPage).execute();
                }
            }
        });


    }

    @Override
    public void update(Observable observable, Object data) {
        DataCenter.flag flag = (DataCenter.flag) data;

        if (!HttpUtils.isConnected()) {
            progressBar.setVisibility(View.GONE);
            no_content_view.setVisibility(View.VISIBLE);
            secondHandCarList.onRefreshComplete();
            secondHandCarList.onLoadMoreComplete(false);
        }

        if (flag == DataCenter.flag.GET_SECOND_HAND_CAR_LIST_SUCCESS
                || flag == DataCenter.flag.GET_SECOND_HAND_CAR_FAILED) { //类表数据
            //  secondHandCarLists.addAll(DataCenter.secondHandCar);

            secondHandCarList.setVisibility(View.VISIBLE); // listview
            progressBar.setVisibility(View.GONE);
            no_content_view.setVisibility(View.GONE);

            secondHandCarList.onRefreshComplete();
            secondHandCarList.onLoadMoreComplete(false);
            secondHandCarAdapter.notifyDataSetChanged();


            if (flag == DataCenter.flag.GET_SECOND_HAND_CAR_LIST_SUCCESS) {
                // Log.d(DataCenter.LOG_INFO, " DdcListActivity.update() -> SUCCESS");
                if ((secondHandCarLists == null || secondHandCarLists.size() < 1)) {
                    no_content_view.setVisibility(View.VISIBLE);
                    secondHandCarList.setVisibility(View.INVISIBLE);
                    ((TextView) no_content_view.findViewById(R.id.notice_msg_tv)).setText(getText(R.string.listview_msg_empty));
                } else {
                    secondHandCarList.setVisibility(View.VISIBLE);
                    no_content_view.setVisibility(View.GONE);
                }
            }

            if (flag == DataCenter.flag.GET_SECOND_HAND_CAR_FAILED) {
                if ((secondHandCarLists == null || secondHandCarLists.size() < 1)) {
                    no_content_view.setVisibility(View.VISIBLE);
                    secondHandCarList.setVisibility(View.INVISIBLE);
                    ((TextView) no_content_view.findViewById(R.id.notice_msg_tv)).setText(getText(R.string.listview_msg_error));
                } else {
                    no_content_view.setVisibility(View.GONE);
                }
            }
        } else { // 置顶滚动栏数据
            ArrayList<SecondHandCar> topBeanList = DataCenter.secondHandCarTop;
            mTextView02.setData3(topBeanList);
            mTextView02.startRolling();
        }

    }


    @Override
    protected void onRestart() {
        progressBar.setVisibility(View.VISIBLE);
        if (flag) {
            new GetSecondHandCarSearch(DataCenter.index1, DataCenter.brandName, DataCenter.index3, DataCenter.index2, currentPage).execute();
        } else {
            new GetSecondHandCarLIst(catid, currentPage).execute();
        }
        super.onRestart();
    }

    private void findActionBar() {
        actionBarView = (ActionBarView) findViewById(R.id.actionbar);
        actionBarView.setTitle("二手车");
        secondHandCarName.setBackgroundDrawable(getResources().getDrawable(R.drawable.triangle_light));
        secondHandCarName.setTextColor(Color.rgb(245, 142, 111));
        actionBarView.button_right_icon2.setVisibility(View.VISIBLE);
        actionBarView.button_right_icon2.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.publish));
    }

    private void initView() {
        characterParser = CharacterParser.getInstance();
        secondHandCarName = (TextView) findViewById(R.id.secondHandCarName);
        secondHandCarPrice = (TextView) findViewById(R.id.secondHandCarPrice);
        secondHandCarKM = (TextView) findViewById(R.id.secondHandCarKM);
        secondHandCarAge = (TextView) findViewById(R.id.secondHandCarAge);
        secondHandCarName.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (DataCenter.flags1 == 1) {
                    lv_car.setVisibility(View.GONE);
                    rl_car.setVisibility(View.VISIBLE);
                    mTextView02.setVisibility(View.VISIBLE);
                    DataCenter.flags1 = -1;
                } else {
                    lv_car.setVisibility(View.VISIBLE);
                    rl_car.setVisibility(View.GONE);
                    mTextView02.setVisibility(View.GONE);
                    SourceDateList = filledData(getResources().getStringArray(R.array.car_name));
                    pinyinComparator = new PinyinComparator();
                    // 根据a-z进行排序源数据
                    Collections.sort(SourceDateList, pinyinComparator);
                    DataCenter.lmap.clear();
                    sortAdapter = new SortAdapter(SecondHandCarActivity.this, SourceDateList);
                    lv_car.setAdapter(sortAdapter);
                    secondHandCarName.setBackgroundDrawable(getResources().getDrawable(R.drawable.triangle_light));
                    secondHandCarName.setTextColor(Color.rgb(245, 142, 111));
                    secondHandCarKM.setTextColor(Color.rgb(0, 0, 0));
                    secondHandCarAge.setTextColor(Color.rgb(0, 0, 0));
                    secondHandCarPrice.setTextColor(Color.rgb(0, 0, 0));
                    secondHandCarName.setBackgroundDrawable(getResources().getDrawable(R.drawable.triangle_light));
                    secondHandCarPrice.setBackgroundDrawable(getResources().getDrawable(R.drawable.triangle_dark));
                    secondHandCarAge.setBackgroundDrawable(getResources().getDrawable(R.drawable.triangle_dark));
                    secondHandCarKM.setBackgroundDrawable(getResources().getDrawable(R.drawable.triangle_dark));
                    DataCenter.flags1 = 1;
                }

            }
        });

        secondHandCarPrice.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (DataCenter.flags1 == 2) {
                    lv_car.setVisibility(View.GONE);
                    rl_car.setVisibility(View.VISIBLE);
                    mTextView02.setVisibility(View.VISIBLE);
                    DataCenter.flags1 = -1;
                } else {
                    lv_car.setVisibility(View.VISIBLE);
                    rl_car.setVisibility(View.GONE);
                    mTextView02.setVisibility(View.GONE);
                    list1.clear();
                    initViewForPrice();
//                    adapter = new ArrayAdapter(SecondHandCarActivity.this, R.layout.sift_car_other_item, R.id.itemTv, list1);//price 2 list1
                    DataCenter.lmap.clear();
                    adapter = new SecondCarCommonAdapter(SecondHandCarActivity.this, list1);
                    lv_car.setAdapter(adapter);

                    secondHandCarPrice.setTextColor(Color.rgb(245, 142, 111));
                    secondHandCarKM.setTextColor(Color.rgb(0, 0, 0));
                    secondHandCarAge.setTextColor(Color.rgb(0, 0, 0));
                    secondHandCarName.setTextColor(Color.rgb(0, 0, 0));
                    secondHandCarName.setBackgroundDrawable(getResources().getDrawable(R.drawable.triangle_dark));
                    secondHandCarPrice.setBackgroundDrawable(getResources().getDrawable(R.drawable.triangle_light));
                    secondHandCarAge.setBackgroundDrawable(getResources().getDrawable(R.drawable.triangle_dark));
                    secondHandCarKM.setBackgroundDrawable(getResources().getDrawable(R.drawable.triangle_dark));
                    DataCenter.flags1 = 2;
                }
            }
        });
        secondHandCarAge.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (DataCenter.flags1 == 4) {
                    lv_car.setVisibility(View.GONE);
                    rl_car.setVisibility(View.VISIBLE);
                    mTextView02.setVisibility(View.VISIBLE);

                    DataCenter.flags1 = -1;
                } else {
                    lv_car.setVisibility(View.VISIBLE);
                    rl_car.setVisibility(View.GONE);
                    mTextView02.setVisibility(View.GONE);
                    list2.clear();
                    initViewForAge();
//                    adapter = new ArrayAdapter(SecondHandCarActivity.this, R.layout.sift_car_other_item, R.id.itemTv, list2);//age 4 list2
                    DataCenter.lmap.clear();
                    adapter = new SecondCarCommonAdapter(SecondHandCarActivity.this, list2);
                    lv_car.setAdapter(adapter);
                    secondHandCarAge.setTextColor(Color.rgb(245, 142, 111));
                    secondHandCarPrice.setTextColor(Color.rgb(0, 0, 0));
                    secondHandCarKM.setTextColor(Color.rgb(0, 0, 0));
                    secondHandCarName.setTextColor(Color.rgb(0, 0, 0));
                    secondHandCarName.setBackgroundDrawable(getResources().getDrawable(R.drawable.triangle_dark));
                    secondHandCarPrice.setBackgroundDrawable(getResources().getDrawable(R.drawable.triangle_dark));
                    secondHandCarAge.setBackgroundDrawable(getResources().getDrawable(R.drawable.triangle_light));
                    secondHandCarKM.setBackgroundDrawable(getResources().getDrawable(R.drawable.triangle_dark));
                    DataCenter.flags1 = 4;
                }
            }
        });
        secondHandCarKM.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (DataCenter.flags1 == 3) {
                    lv_car.setVisibility(View.GONE);
                    rl_car.setVisibility(View.VISIBLE);
                    mTextView02.setVisibility(View.VISIBLE);
                    DataCenter.flags1 = -1;
                } else {
                    lv_car.setVisibility(View.VISIBLE);
                    rl_car.setVisibility(View.GONE);
                    mTextView02.setVisibility(View.GONE);
                    list3.clear();
                    initViewForKM();
//                    adapter = new ArrayAdapter(SecondHandCarActivity.this, R.layout.sift_car_other_item, R.id.itemTv, list3);//km 3 list3
                    DataCenter.lmap.clear();
                    adapter = new SecondCarCommonAdapter(SecondHandCarActivity.this, list3);
                    lv_car.setAdapter(adapter);
                    secondHandCarKM.setTextColor(Color.rgb(245, 142, 111));
                    secondHandCarAge.setTextColor(Color.rgb(0, 0, 0));
                    secondHandCarPrice.setTextColor(Color.rgb(0, 0, 0));
                    secondHandCarName.setTextColor(Color.rgb(0, 0, 0));
                    secondHandCarName.setBackgroundDrawable(getResources().getDrawable(R.drawable.triangle_dark));
                    secondHandCarPrice.setBackgroundDrawable(getResources().getDrawable(R.drawable.triangle_dark));
                    secondHandCarAge.setBackgroundDrawable(getResources().getDrawable(R.drawable.triangle_dark));
                    secondHandCarKM.setBackgroundDrawable(getResources().getDrawable(R.drawable.triangle_light));
                    DataCenter.flags1 = 3;
                }
            }
        });

        lv_car.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (DataCenter.flags1 == 1) {
                    DataCenter.index = position;
                    TextView textview = null;
                    ImageView imageView = null;
                    textview = (TextView) DataCenter.lmap.get(DataCenter.index).findViewById(R.id.title);
                    imageView = (ImageView) DataCenter.lmap.get(DataCenter.index).findViewById(R.id.itemIv);
                    textview.setTextColor(getResources().getColor(R.color.title_detail_color));
                    imageView.setVisibility(View.VISIBLE);
                    secondHandCarName.setText(SourceDateList.get(position).getName());
                    DataCenter.brandName = SourceDateList.get(position).getName();
                    if (DataCenter.brandName.equals("#全部品牌")) {
                        DataCenter.brandName = "";
                    }
                } else if (DataCenter.flags1 == 3) {
                    DataCenter.index2 = position;
                    TextView textview = null;
                    ImageView imageView = null;
                    //对ListView中的ChildView进行操纵。。。
                    textview = (TextView) DataCenter.lmap.get(DataCenter.index2).findViewById(R.id.itemTv);
                    imageView = (ImageView) DataCenter.lmap.get(DataCenter.index2).findViewById(R.id.itemIv);
                    textview.setTextColor(getResources().getColor(R.color.title_detail_color));
                    imageView.setVisibility(View.VISIBLE);
                    secondHandCarKM.setText(list3.get(position));
                }
                if (DataCenter.flags1 == 2) {
                    DataCenter.index1 = position;
                    TextView textview = null;
                    ImageView imageView = null;
                    //对ListView中的ChildView进行操纵。。。
                    Log.d("DataCenter.index1", DataCenter.index1 + "====");
                    textview = (TextView) DataCenter.lmap.get(DataCenter.index1).findViewById(R.id.itemTv);
                    imageView = (ImageView) DataCenter.lmap.get(DataCenter.index1).findViewById(R.id.itemIv);
                    textview.setTextColor(getResources().getColor(R.color.title_detail_color));
                    imageView.setVisibility(View.VISIBLE);
                    secondHandCarPrice.setText(list1.get(position));
                } else if (DataCenter.flags1 == 3) {
                    DataCenter.index2 = position;
                    TextView textview = null;
                    ImageView imageView = null;
                    //对ListView中的ChildView进行操纵。。。
                    textview = (TextView) DataCenter.lmap.get(DataCenter.index2).findViewById(R.id.itemTv);
                    imageView = (ImageView) DataCenter.lmap.get(DataCenter.index2).findViewById(R.id.itemIv);
                    textview.setTextColor(getResources().getColor(R.color.title_detail_color));
                    imageView.setVisibility(View.VISIBLE);
                    secondHandCarKM.setText(list3.get(position));
                } else if (DataCenter.flags1 == 4) {
                    DataCenter.index3 = position;
                    TextView textview = null;
                    ImageView imageView = null;
                    //对ListView中的ChildView进行操纵。。。
                    textview = (TextView) DataCenter.lmap.get(DataCenter.index4).findViewById(R.id.itemTv);
                    imageView = (ImageView) DataCenter.lmap.get(DataCenter.index4).findViewById(R.id.itemIv);
                    textview.setTextColor(getResources().getColor(R.color.title_detail_color));
                    imageView.setVisibility(View.VISIBLE);
                    secondHandCarAge.setText(list2.get(position));
                }
                lv_car.setVisibility(View.GONE);
                rl_car.setVisibility(View.VISIBLE);
                mTextView02.setVisibility(View.VISIBLE);
                if (DataCenter.brandName == null) {
                    DataCenter.brandName = "";
                }
                progressBar.setVisibility(View.VISIBLE);
                new GetSecondHandCarSearch(DataCenter.index1, DataCenter.brandName, DataCenter.index3, DataCenter.index2, page).execute();
                flag = true;
            }
        });

    }

    private void initTag() {
        secondHandCarName.setBackgroundDrawable(getResources().getDrawable(R.drawable.triangle_dark));
        secondHandCarPrice.setBackgroundDrawable(getResources().getDrawable(R.drawable.triangle_dark));
        secondHandCarAge.setBackgroundDrawable(getResources().getDrawable(R.drawable.triangle_dark));
        secondHandCarKM.setBackgroundDrawable(getResources().getDrawable(R.drawable.triangle_dark));
    }

    /**
     * 为ListView填充数据
     *
     * @param date
     * @return
     */
    private List<SortModel> filledData(String[] date) {
        List<SortModel> mSortList = new ArrayList<SortModel>();

        for (int i = 0; i < date.length; i++) {
            SortModel sortModel = new SortModel();
            sortModel.setName(date[i]);
            //汉字转换成拼音
            String pinyin = characterParser.getSelling(date[i]);
            String sortString = pinyin.substring(0, 1).toUpperCase();

            // 正则表达式，判断首字母是否是英文字母
            if (sortString.matches("[A-Z]")) {
                sortModel.setSortLetters(sortString.toUpperCase());
            } else {
                sortModel.setSortLetters("#");
            }

            mSortList.add(sortModel);
        }
        return mSortList;

    }

    /**
     * 价格筛选页面的初始化
     */
    private void initViewForPrice() {
        list1.add("不限");
        list1.add("1万以下");
        list1.add("1-3万");
        list1.add("3-5万");
        list1.add("5-10万");
        list1.add("10-15万");
        list1.add("15-20万");
        list1.add("20-25万");
        list1.add("25-40万");
        list1.add("40万以上");
    }

    /**
     * 公里筛选页面的初始化
     */
    private void initViewForKM() {
        list3.add("不限");
        list3.add("一万公里以内");
        list3.add("1-3万公里");
        list3.add("3-5万公里");
        list3.add("5-8万公里");
        list3.add("8-10万公里");
        list3.add("10万公里以上");
    }

    /**
     * 车龄筛选页面的初始化
     */
    private void initViewForAge() {
        list2.add("不限");
        list2.add("1年以下");
        list2.add("1-3年");
        list2.add("3-5年");
        list2.add("5-8年");
        list2.add("8-10年");
        list2.add("10年以上");
    }


    @Override
    public void onDestroy() {
        super.onDestroy();
        LogUtil.d(DataCenter.LOG_INFO, secondHandCarActivity + ".onDestroy");
        DataCenter.secondHandCarTop.clear();
        DataCenter.brandName = null;
        DataCenter.index = 0;
        DataCenter.index1 = 0;
        DataCenter.index2 = 0;
        DataCenter.index3 = 0;
        DataCenter.flags1 = -1;
        //删除观察者
        DataCenter.getInstance().deleteObserver(this);
    }
}
